"""
https://leetcode.cn/problems/number-of-equivalent-domino-pairs
"""

from typing import List


class Solution:
    def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
        showed = [[0] * 10 for _ in range(10)]
        res = 0
        for a, b in dominoes:
            res += showed[a][b]
            if a != b:
                res += showed[b][a]
            showed[a][b] += 1
        return res


dominoes = [[1, 1], [2, 2], [1, 1], [1, 2], [1, 2], [1, 1]]
print(Solution().numEquivDominoPairs(dominoes))
